/*
 * JStellaHelp.java
 *
 * Created on August 19, 2007, 11:57 PM
 */

package jstella.runner;
import java.awt.*;
import javax.swing.*;

/**
 *
 * @author  Sysop
 */
public class JStellaHelp extends javax.swing.JDialog {
    
    private static java.util.List<JSHelpTopic> myHelpTopicList=new java.util.ArrayList<JSHelpTopic>();
    
    static {
      
        myHelpTopicList.add( new JSHelpTopic("General", 
		"JStella is an open-source Atari 2600 emulator based on the Stella Atari 2600 emu"
		 + "lator.  JStella is programmed in Java, and it is currently hosted by SourceForge"
		 + ".net.\n"
		 + "This is a pre-release version of JStella.  It is not fully functional yet.  Even"
		 + " though you should expect bugs, we would appreciate it if you would report them "
		 + "on the JStella site at SourceForge.net (project name is jstella).  \n"
		 + "")); //constructed with HelpTool
        
       myHelpTopicList.add( new JSHelpTopic("Default Keyboard Controls", 
		"The keyboard controls can be configured in the Configuration window, available"
		 + " from the main menu.\n"
		 + "The following are some of the default controls.  Depending on your current confi"
		 + "guration, these may or may not be applicable.\n"
		 + "User Arrow Keys = 2600 Joystick A: directions\n"
		 + "User  Spacebar = 2600 Joystick A: button")); //constructed with HelpTool 
        
        myHelpTopicList.add( new JSHelpTopic("Mouse Controls", 
		"JStella can use the mouse for a variety of different controls.\n"
		 + "\n"
		 + "Mouse Paddle: The mouse wheel will simulate the 2600 Paddle Controller A.  Also,"
		 + " the right mouse button will toggle Mouse-Paddle-Mode, in which the mouse cursor"
		 + " disappears, and the paddle will move based on the movement of the mouse.  The l"
		 + "eft mouse button acts as the trigger for Paddle A.\n"
		 + "\n"
		 + "Virtual Joystick: You can use the Virtual Joystick by clicking the corresponding"
		 + " option on the main menu.  It will display a window with an image of a 2600 joys"
		 + "tick.  You can reposition the window by dragging it with either the right or mid"
		 + "dle mouse button.  The right mouse button will also emulate the joystick button."
		 + " \n"
		 + "The left mouse button can be used to either drag the joystick head in the direct"
		 + "ion you wish to move, or if clicked away from the joystick head, will automatica"
		 + "lly move the joystick in that direction.\n"
		 + "\n"
		 + "")); //constructed with HelpTool
        
        
        
        myHelpTopicList.add( new JSHelpTopic("Console Switches", 
		"F1 = reset � often used to both start and reset a game (depends on the game)\n"
		 + "F2 = select � shifts to the next configuration�if in a game, may take you back t"
		 + "o main screen.\n"
		 + "F3 = set �TV Type� to black-and-white mode\n"
		 + "F4 = set �TV Type� to color mode\n"
		 + "F5 = set �Left Player Difficulty� to B (amateur)\n"
		 + "F6 = set �Left Player Difficulty� to A (professional)\n"
		 + "F7 = set �Right Player Difficulty� to B (amateur)\n"
		 + "F8 = set �Right Player Difficulty� to A (professional)\n"
		 + "\n"
		 + "Note: Many 2600 games use the reset switch as a means of starting the game\n"
		 + "Note: It is up to the game�s software to implement the console switch behavior. "
		 + " For example, not all games will implement a black-and-white mode.  Other games "
		 + "may use the player difficulty switch as a method of pausing the game.   \n"
		 + "\n"
		 + "     ")); //constructed with HelpTool
        
    }//end : static init
    
    private TopicListModel myTopicListModel=new TopicListModel();
    
    
    
    /** Creates new form JStellaHelp */
    private JStellaHelp(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        ListBoxTopics.setModel(myTopicListModel);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        SplitPaneCenter = new javax.swing.JSplitPane();
        SPTopics = new javax.swing.JScrollPane();
        ListBoxTopics = new javax.swing.JList();
        SPContent = new javax.swing.JScrollPane();
        TPContent = new javax.swing.JTextPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("JStella Help");
        SplitPaneCenter.setDividerLocation(150);
        ListBoxTopics.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ListBoxTopics.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                ListBoxTopicsValueChanged(evt);
            }
        });

        SPTopics.setViewportView(ListBoxTopics);

        SplitPaneCenter.setLeftComponent(SPTopics);

        TPContent.setEditable(false);
        TPContent.setFont(new java.awt.Font("Tahoma", 1, 11));
        SPContent.setViewportView(TPContent);

        SplitPaneCenter.setRightComponent(SPContent);

        getContentPane().add(SplitPaneCenter, java.awt.BorderLayout.CENTER);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-432)/2, (screenSize.height-346)/2, 432, 346);
    }// </editor-fold>//GEN-END:initComponents

    private void ListBoxTopicsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_ListBoxTopicsValueChanged
         updateContents();
    }//GEN-LAST:event_ListBoxTopicsValueChanged
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JStellaHelp(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
    
    //TODO : use HTML for help
    
    private void updateContents()
    {
         int zSelectedIndex=ListBoxTopics.getSelectedIndex();
         if (zSelectedIndex==-1) 
         {
             TPContent.setText("");
         }//end : nothing selected
         else 
         {
             TPContent.setText(myHelpTopicList.get(zSelectedIndex).getContent());
         }//end : something selected
    }
    
    
    public static void runJStellaHelp(java.awt.Frame aParent)
    {
        JStellaHelp zJSH=new JStellaHelp(aParent, true);
        zJSH.setLocationRelativeTo(aParent);
        zJSH.setVisible(true);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList ListBoxTopics;
    private javax.swing.JScrollPane SPContent;
    private javax.swing.JScrollPane SPTopics;
    private javax.swing.JSplitPane SplitPaneCenter;
    private javax.swing.JTextPane TPContent;
    // End of variables declaration//GEN-END:variables
    
    public class TopicListModel extends javax.swing.AbstractListModel
    {
        public int getSize() {
            return myHelpTopicList.size();
        }

        public Object getElementAt(int index) {
            return myHelpTopicList.get(index);
        }
        
    }
    
    
    //=======================================
    public static class JSHelpTopic
    {
        private String myTopicName="";
        private String myContent="";
        
        public JSHelpTopic(String aTopicName, String aContent)
        {
            myTopicName=aTopicName;
            myContent=aContent;
        }
        
        public String toString()
        {
            return myTopicName;
        }
        
        public String getContent()
        {
            return myContent;
        }
        
        
    }
    
    
    //==================================================================
    //                       SOURCE TEXT FOR HELP 
    //==================================================================
    //Cut and paste into HelpTool in jstella.debug package to create code, which should be pasted 
    //in the static init part of this class.
    
  /*  
    General
JStella is an open-source Atari 2600 emulator based on the Stella Atari 2600 emulator.  JStella is programmed in Java, and it is currently hosted by SourceForge.net.
This is a pre-release version of JStella.  It is not fully functional yet.  Even though you should expect bugs, we would appreciate it if you would report them on the JStella site at SourceForge.net (project name is �jstella�).  



Default Controls
The keyboard controls can be configured in the �Configuration� window, available from the main menu.
The following are some of the default controls.  Depending on your current configuration, these may or may not be applicable.
User Arrow Keys = 2600 Joystick A: directions
User  Spacebar = 2600 Joystick A: button


Mouse Controls
JStella can use the mouse for a variety of different controls.

Mouse Paddle: The mouse wheel will simulate the 2600 Paddle Controller A.  Also, the right mouse button will toggle Mouse-Paddle-Mode, in which the mouse cursor disappears, and the paddle will move based on the movement of the mouse.  The left mouse button acts as the trigger for Paddle A.

Virtual Joystick: You can use the Virtual Joystick by clicking the corresponding option on the main menu.  It will display a window with an image of a 2600 joystick.  You can reposition the window by dragging it with either the right or middle mouse button.  The right mouse button will also emulate the joystick button. 
The left mouse button can be used to either drag the joystick head in the direction you wish to move, or if clicked away from the joystick head, will automatically move the joystick in that direction.




Console Switches
F1 = reset � often used to both start and reset a game (depends on the game)
F2 = select � shifts to the next configuration�if in a game, may take you back to main screen.
F3 = set �TV Type� to black-and-white mode
F4 = set �TV Type� to color mode
F5 = set �Left Player Difficulty� to B (amateur)
F6 = set �Left Player Difficulty� to A (professional)
F7 = set �Right Player Difficulty� to B (amateur)
F8 = set �Right Player Difficulty� to A (professional)

Note: Many 2600 games use the reset switch as a means of starting the game
Note: It is up to the game�s software to implement the console switch behavior.  For example, not all games will implement a black-and-white mode.  Other games may use the player difficulty switch as a method of pausing the game.   

     
     */
     
     
     
     
     
     
     
     
    
    
    
    
    
}
